﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace BankSystem.Classes
{
    internal class Bank
    {
        const bool TYPE_ATM=true;
        const bool TYPE_ACCOUNT=false;
        const double MAX_ATMSTORE = 1000000;

        private string name;
        List<Account> accountsList=new List<Account>();
        private static int toGenerateIdAccount = 0;
        List<ATM>ATMsList = new List<ATM>();
        private static int toGenerateIdATM = 0;

        public string Name {  get { return name; } }
        public List<Account>Accounts { get { return accountsList; } }
        public List<ATM> ATMs { get { return ATMsList; } }

        public Bank(string name)
        {
            this.name = name;
        }

        public Account AddAccount(string password)
        {
            ID id=new ID();
            id.bank = name;
            id.number = toGenerateIdAccount++;
            id.type = TYPE_ACCOUNT;
            Account account = new CreditAccount(name, id, password, 0);
            accountsList.Add(account);
            return account;
        }

        public ATM AddATM()
        {
            ID id = new ID();
            id.bank = name;
            id.number = toGenerateIdATM++;
            id.type = TYPE_ATM;
            ATM atm = new ATM(name,id,MAX_ATMSTORE/2,MAX_ATMSTORE);
            ATMsList.Add(atm);
            return atm;
        }

        public bool checkIfContainAccount(Account account)
        {
            return name.Equals(account.getBank());
        }
    }
}
